DATA SEGMENT	
	BUF DB 6, 7, 8, 9, 1, 2, 3, 4, 5
	N EQU $-BUF
	MAX DB ?
	MIN DB ?
DATA ENDS

STACK SEGMENT STACK
	DB 200 DUP(0)
STACK ENDS

CODE SEGMENT
	ASSUME CS:CODE,DS:DATA,SS:STACK
START:
	MOV AX,DATA
	MOV DS,AX
	MOV SI,OFFSET BUF
	MOV CX,N
	CALL MAXMIN
	MOV MAX,BH
	MOV MIN,BL
	MOV AH,4CH
	INT 21H
MAXMIN PROC
	PUSH AX
	MOV BH,[SI]
	MOV BL,BH
	DEC CX
A1:
	INC SI
	MOV AL,[SI]
	CMP AL,BH
	JBE	A2
	MOV BH,AL
	JMP A3
A2:
	CMP AL,BL
	JAE A3
	MOV BL,AL
A3:
	LOOP A1
	POP AX
	RET
MAXMIN ENDP
CODE ENDS
END START
		